<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" href="lib/layui/css/layui.css">
    <link rel="stylesheet" href="css/shop-create.css">
</head>
<body>
<div class="layui-card main-panel">
    <div class="layui-card-header">创建商铺</div>
    <div class="layui-card-body">
        <form class="layui-form" action="">
            <div class="layui-form-item">
                <label class="layui-form-label">商铺名称</label>
                <div class="layui-input-block">
                    <input type="text" name="name" required lay-verify="required" placeholder="请输入名称"
                           autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">账户名称</label>
                <div class="layui-input-inline">
                    <input type="text" name="loginName" required lay-verify="required" placeholder="请输入账户名称"
                           autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">商家登录时使用</div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">账户密码</label>
                <div class="layui-input-inline">
                    <input type="password" name="password" required lay-verify="required" placeholder="请输入账户密码"
                           autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">商家登录时使用</div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">商铺地址</label>
                <div class="layui-input-block">
                    <input type="text" name="address" required lay-verify="required" placeholder="请输入地址"
                           autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">营业时间</label>
                <div class="layui-input-block">
                    <input type="text" name="dailyHours" required lay-verify="required" placeholder="请输入营业时间"
                           autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">扫呗商户号</label>
                <div class="layui-input-inline">
                    <input type="text" name="merchantNo" required lay-verify="required" placeholder="请输入商户号"
                           autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">登录扫呗后台获取</div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">扫呗终端号</label>
                <div class="layui-input-inline">
                    <input type="text" name="terminalId" required lay-verify="required" placeholder="请输入终端号"
                           autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">登录扫呗后台获取</div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">扫呗口令</label>
                <div class="layui-input-inline">
                    <input type="text" name="accessToken" required lay-verify="required" placeholder="请输入口令"
                           autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">登录扫呗后台获取</div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">支付地址</label>
                <div class="layui-input-inline">
                    <input type="text" name="generalPayUrl" required lay-verify="required" placeholder="请输入支付地址"
                           autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">登录扫呗后台获取</div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit lay-filter="formDemo">创建商铺</button>
                    <button type="reset" class="layui-btn layui-btn-primary">重置数据</button>
                </div>
            </div>
        </form>
    </div>
</div>
<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
<script src="lib/layui/layui.js"></script>
<script>
    layui.use('form', function () {
        var form = layui.form;

        //监听提交
        form.on('submit(formDemo)', function (data) {
            var postData = data.field;
            $.ajax({
                type: 'POST',
                url: 'backstage/shop/',
                contentType: 'application/json;charset=utf-8',
                dataType: 'json',
                data: JSON.stringify(postData),
                success: function (res) {
                    if (res.code === 200) {
                        layer.msg('创建成功');
                        window.location.href = 'shop-list.html';
                    } else {
                        layer.msg(res.msg);
                    }
                },
                error: function (err) {
                    console.log(err);
                }
            });
            return false;
        });
    });
</script>
</body>
</html>
